from django.db import models

# 用户表
class User(models.Model):
    account = models.CharField(verbose_name="账号", max_length=64, blank=False)
    username = models.CharField(verbose_name="用户名", max_length=64, blank=False)
    password = models.CharField(verbose_name="密码", max_length=128, blank=False)
    avatar_url = models.CharField(verbose_name="用户头像图片url", max_length=64, blank=True)
    create_datetime = models.DateTimeField(verbose_name='创建时间', auto_now_add=True)
    token = models.CharField(verbose_name="token", max_length=64, null=True, blank=True, db_index=True)
    
    # 角色
    STUDENT = 'student'
    TEACHER = 'teacher'
    ROLE_CHOICES = [
        (STUDENT, '学生'),
        (TEACHER, '教师'),
    ]
    role = models.CharField(verbose_name="角色", max_length=10, choices=ROLE_CHOICES, default=STUDENT)

    def __str__(self):
        return self.account
